<?php

use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateUsers extends Migration
{
    /**
     * Run the migrations.
     *创建表
     * @return void
     */
    public function up()
    {
        //检查表是否存在
        if (!Schema::hasTable('users')) {
        //创建数据表
             Schema::create('users', function (Blueprint $table) {
                $table->increments('id');
                $table->string('username');
                $table->string('password');
                // $table->string('img');
                $table->string('email');
                $table->timestamps();
            });
        }else{
            //创建字段
            Schema::table('users', function ($table) {
                //检查字段是否存在,如果不存在就添加
                // if (!Schema::hasColumn('users', 'repassword')) {
                //     $table->string('repassword');
                // }
                // if (Schema::hasColumn('users', 'repassword')) {
                //      $table->dropColumn('repassword');
                // }
            });
        }
    }

    /**
     * Reverse the migrations.
     *删除表
     * @return void
     */
    public function down()
    {
        //删除表
       // Schema::drop('flights');
    }
}
